﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
using System.Windows.Media;

namespace SYcwpb.ViewModels
{
    //定义值转换器
    [ValueConversion(typeof(string), typeof(string))]
    public class GroupBackGroundColor : IValueConverter
    {
        public static int countOne = 0;
        public static int countTwo = 0;
        public static int countThree = 0;
        public static int countFour = 0;

        //public GroupBackGroundColor()
        //{
        //    countOne = 0;
        //    countTwo = 0;
        //    countThree = 0;
        //    countFour = 0;
        //}
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string strValue = value.ToString();
            int line = System.Convert.ToInt32(parameter);


            if (strValue == "1")
            {
                countOne++;
                //if (countOne % 2 == 0)
                if(line==0)
                {
                    return new SolidColorBrush(Colors.White);
                }
                else
                {
                    //return new SolidColorBrush(Colors.SkyBlue);
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffede0"));
                }
            }
            else if (strValue == "2")
            {
                countTwo++;
                //if (countTwo % 2 == 0)
                if (line == 0)
                {
                    return new SolidColorBrush(Colors.White);
                }
                else
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ebbe9c"));

                }
            }
            else if (strValue == "3")
            {
                countThree++;
                //if (countThree % 2 == 0)
                if (line == 0)
                {
                    return new SolidColorBrush(Colors.White);
                }
                else
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#e3facb"));
                }
            }
            else
            {
                countFour++;
                //if (countFour % 2 == 0)
                if (line == 0)
                {
                    return new SolidColorBrush(Colors.White);
                }
                else
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b4d88e"));
                }
            }
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return "";
        }
    }
}
